package com.wzqj.agent.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.wzqj.agent.common.JsonOutput;
import com.wzqj.agent.common.exception.BusinessErrorType;
import com.wzqj.agent.common.exception.BusinessException;
import com.wzqj.agent.web.service.BizClassifyService;
/**
 * 行业信息Controller
 * @author gz
 */
@Controller
@RequestMapping("/bizClassify")
public class BizClassifyController {

	@Autowired
	private BizClassifyService bizClassifyService;
	/**
	 * 下级行业信息
	 * @param id
	 * @param childClassify
	 * @return
	 */
	@RequestMapping("/childClassify")
	@ResponseBody
	public JSONObject childClassify(@RequestParam(value = "id", defaultValue = "")  Integer id,
			@RequestParam(value = "childClassify", defaultValue = "")  String childClassify,
			@RequestParam(value = "level", defaultValue = "1")  Integer level){
		JsonOutput output = new JsonOutput();
		
		JSONArray data = new JSONArray();
		try {
			data = bizClassifyService.childClassify(id,childClassify,level);
			if (data!=null) {
				output.setData(data.toString());
			}
		} catch (BusinessException e) {
            output.setErrCode(e.getErrCode());
            output.setRetCode(e.getInnerErrCode());
            output.setMsg(e.getErrMsg());
		}
		return output.toJSONObject();
	}
	
	
}
